package cn.quevo.core.entity;

import cn.quevo.core.enums.EnumsInterface;
import cn.quevo.core.enums.ResultStatusEnum;
import cn.quevo.core.lang.NumberUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 返回结果
 *
 * @author July july_sky@foxmail.com
 * @date 2018-03-09 14:54:28
 * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
 * @version 1.0
 * @return
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ResponseResult extends ResultEntity {

    /** 额外信息 */
    private Object data;
    /**
     * 
     */
    private static final long serialVersionUID = -874039914230807080L;

    public ResponseResult(EnumsInterface enums) {
        this(enums, null);
    }

    public ResponseResult(Integer status, String msg) {
        this(status, msg, null);
    }

    public ResponseResult(Integer status, String msg, Object data) {
        super(status, msg);
        this.data = data;
    }

    public ResponseResult(EnumsInterface enums, Object data) {
        this(NumberUtils.toInt(enums.getCode().toString(), 5000), enums.getValue(), data);
    }

    public static ResponseResult success(Object data) {
        return new ResponseResult(ResultStatusEnum.SUCCESS.getCode(), ResultStatusEnum.SUCCESS.getValue(), data);
    }
}